﻿import React from 'react';
import ReactDOM from 'react-dom';
import {actions, connect, Link} from 'mirrorx';
import { List, Button, WhiteSpace, WingBlank,} from 'antd-mobile';

const Item = List.Item;
const Brief = Item.Brief;

import { FormattedMessage} from 'react-intl';


class App extends React.Component { 
	constructor(props) {
		super(props);
		this.state ={
			bankcardInfo:{}
		}
	}

	componentDidMount(){

		T.fetch({
				url: "/bank/card/info/"+T.urlQuery("cardNo")+".json",
				data: {},
			}).then((res) => {
				if (res.success) {
					this.setState({
						bankcardInfo:res.value
					})
				}
		});
		
    }
	manage = (cardNo) => { //跳转去修改信用卡有效期
		actions.routing.push({
			pathname: 'bankcard-creditcard',
            search: '?cardNo='+T.urlQuery("cardNo")
		})

	}
	unBindCard = () => {  //解除绑定银行卡
		T.fetch({
				url: "/bank/card/unbind/"+T.urlQuery("bankInfoId")+".json",
				data: {},
			}).then((res) => {
				if (res.success) {
					actions.routing.push({
						pathname: 'bankcard-list',						
					})
				}
		});
	}
	
	render() {
		const info = this.state.bankcardInfo;
		return (<div className="bankcard-info">		    
			 <WhiteSpace/>
			 <Item  multipleLine onClick={() => {}}>
         		 {info.bankName}<Brief>{T.urlQuery("cardNo")}</Brief>
			  </Item>
			 <WhiteSpace/>
			  <WhiteSpace/>
			  <WingBlank>
			  {/*<Button className="diy_background" type="primary" onClick={this.manage}>信用卡延长有效期</Button>*/}
			  </WingBlank>
			  <WhiteSpace/>
			  <WhiteSpace/>
			  <WingBlank>
			  <Button className="diy_background" type="primary" onClick={this.unBindCard}><FormattedMessage id='cancel_bind' defaultMessage='解除绑定'/> </Button>
			  </WingBlank>
	  	</div>)
	}
}

export default App;